package com.yswwpp.cross.wan;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.logging.ConsoleHandler;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;

public class Start
{


	public static void main(String[] agre) throws IOException, InterruptedException
	{

		ServerBootstrap bootstrap;
		EventLoopGroup boss = new NioEventLoopGroup(1);
		EventLoopGroup worker = new NioEventLoopGroup();

		bootstrap = new ServerBootstrap();
		bootstrap.group(boss, worker).channel(NioServerSocketChannel.class)
				.handler(new LoggingHandler(LogLevel.INFO))
				/*.childHandler(new ChannelInitializer<SocketChannel>()
				{
					@Override
					public void initChannel(SocketChannel ch) throws Exception
					{
						ChannelPipeline p = ch.pipeline();
						p.addLast(new ConsoleHandler());
					}
				})*/;

		// Start the client.
		ChannelFuture ch = bootstrap.bind(8080).sync();


		// Wait until the connection is closed.
		ch.channel().closeFuture().sync();

	}
}
